/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.language.factories;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import ac.jp.u_tokyo.SyncLib.SwitchCombinator;
import ac.jp.u_tokyo.SyncLib.Sync;
import ac.jp.u_tokyo.SyncLib.SyncFactory;

public class SwitchCombinatorFactory implements SyncFactory
{
	
	private List<SyncFactory> _innerFactories = new LinkedList<SyncFactory>();
	
	public void addFactory(SyncFactory f) {
		_innerFactories.add(f);
	}

	public Sync create()
	{
		Sync[] sync = new Sync[_innerFactories.size()];
		Iterator<SyncFactory> it = _innerFactories.iterator();
		for (int i = 0; i < sync.length; i++) {
			sync[i] = it.next().create();
		}
		return new SwitchCombinator(sync);
	}
	
	

}
